Security News
NIST Misses 2024 Deadline to Clear NVD Backlog
NIST has failed to meet its self-imposed deadline of clearing the NVD's backlog by the end of the fiscal year. Meanwhile, CVE's awaiting analysis have increased by 33% since June.
@empathyco/x-storage-service
Advanced tools
Storage Service is a wrapper on top of the Web Storage API that provides additional features such as key prefixing and TTL.
By default, Storage Service works with localStorage
and using empathy
as prefix. If that sounds good, you can just do:
const storage = new StorageService()
You can also customize the storage or prefix to be used in the constructor:
StorageService(storage?, prefix?)
For instance, if you want to use sessionStorage
and test
as prefix instead:
const storage = StorageService(sessionStorage, 'test')
Storage Service provides four public functions: setItem
, getItem
, removeItem
and clear
.
storage.setItem('x', { a: 'this', b: 'can', c: 'be', d: 'anything' })
With the default configuration, this will set an item in localStorage
with the key empathy
and no TTL.
const item = storage.getItem('x') // Returns the item
const item = storage.removeItem('x') // Also returns the item!
const removedItemCount = storage.clear() // Returns the number of items that have been removed
The setItem
function provides an optional third parameter to specify a time-to-live in milliseconds:
storage.setItem('x', 'value', 50)
After the specified time, the item won't be available via getItem
or removeItem
. Expired items are automatically removed from storage to avoid consuming space unnecessarily.
FAQs
Storage service with TTL
The npm package @empathyco/x-storage-service receives a total of 1,525 weekly downloads. As such, @empathyco/x-storage-service popularity was classified as popular.
We found that @empathyco/x-storage-service demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 5 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
NIST has failed to meet its self-imposed deadline of clearing the NVD's backlog by the end of the fiscal year. Meanwhile, CVE's awaiting analysis have increased by 33% since June.
Security News
Cloudflare has launched a setup wizard allowing users to easily create and manage a security.txt file for vulnerability disclosure on their websites.
Security News
The Socket Research team breaks down a malicious npm package targeting the legitimate DOMPurify library. It uses obfuscated code to hide that it is exfiltrating browser and crypto wallet data.